// import React from 'react'
// import {  BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'

// const Home = React.lazy(() => import('../pages/home'))
// const Layout = React.lazy(() => import('../pages/layout'))
// const Login = React.lazy(() => import('../pages/login'))
// const Set = React.lazy(() => import('../pages/set'))
// const Table = React.lazy(() => import('../pages/table'))
// const My = React.lazy(() => import('../pages/my'))

// type Props = {}
// const index = (props: Props) => {
// 	return (
// 		/* 路由模式 */
// 		<BrowserRouter>
// 		{/* 一次只能匹配第一个路由 */}
// 			<Routes>
// 				{/* 一级路由 */}
// 				<Route path='/' element={ <Layout></Layout> }>
// 					{/* 二级路由 */}
// 					<Route path='/home' element={ <Home></Home> }></Route>
// 					<Route path='/table' element={ <Table></Table> }></Route>
// 					<Route path='/set' element={ <Set></Set> }></Route>
// 					<Route path='/my' element={ <My></My> }></Route>
// 					{/* 重定向 */}
// 					<Route path='/' element={ <Navigate to={'/home'}></Navigate> }></Route
// 				</Route>
// 				<Route path='/login' element={ <Login></Login> }></Route>
// 			</Routes>
// 		</BrowserRouter>
// 	)
// }

// export default index

/***************************************************************/
import React from 'react'
import { BrowserRouter, Routes, Route,  PathRouteProps } from 'react-router-dom'
import routes, { RouteType } from './routes'
type Props = {}

const beforeEach = (wrapperComponent: React.FC | React.ClassicComponentClass) => {
	return () => {

	}
}


const routerView = (routes: RouteType[]) => {
	return (
		<>
			{
				routes.length > 0 && routes.map((v, i) => {
					return <Route key={i} path={v.path} element={ <v.element></v.element> }>{ v.children && routerView(v.children) }</Route>
				})
			}
		</>
	)
}

const Index = (props: Props) => {
	return (
		<BrowserRouter>
			<Routes>
				{
					routerView(routes)
				}
			</Routes>
		</BrowserRouter>
	)
}

export default Index